﻿using System;
using System.Collections.Generic;
using FlowCanvas;
using FlowCanvas.Nodes;
using LogSystem;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class StreetEventHittableTargetGroupComplete : EventNode
    {
        public BBParameter<List<int>> WarmUpGroupIds;

        public static Action<int> OnGroupComplete;
        
        private FlowOutput onWarmUpComplete;
        private FlowOutput onCommonComplete;
        
        protected override void RegisterPorts()
        {
            onWarmUpComplete = AddFlowOutput("onWarmUpComplete");
            onCommonComplete = AddFlowOutput("onCommonComplete");
        }

        public override void OnGraphStarted()
        {
            OnGroupComplete += OnGroupCompleteFunc;
        }

        public override void OnGraphStoped()
        {
            OnGroupComplete -= OnGroupCompleteFunc;
        }

        private void OnGroupCompleteFunc(int groupId)
        {
            if (WarmUpGroupIds.value.Contains(groupId))
            {
                onWarmUpComplete.Call(new Flow());
            }
            else
            {
                onCommonComplete.Call(new Flow());
            }
        }
    }
}